package com.mybatisplus.controller;

import com.mybatisplus.entity.BaseResultBean;
import com.mybatisplus.entity.Teacher;
import com.mybatisplus.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author : 郭政荣
 * @Date : 2023/5/18 22:23
 **/
@RestController
@RequestMapping("/teacher")
public class TeacherController {
    @Autowired
    private TeacherService teacherService;

    @RequestMapping("/getTeacher")
    public Teacher getTeacherByTeacherID(HttpServletRequest request) {
        //通过教师工号获取教师
        return teacherService.selectTeacherById(request.getParameter("stuid"));
    }

    @RequestMapping("/alterPassword")
    public BaseResultBean alterPwd(HttpServletRequest request) {
        //修改密码
        BaseResultBean bean = new BaseResultBean();
        String stuid = request.getParameter("stuid");
        String newPassword = request.getParameter("newPassword");
        bean = teacherService.alterPassword(stuid, newPassword, request);
        return bean;
    }
}
